/**
 * 
 */
package com.et114.modules.org.cells;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.extremecomponents.table.bean.Column;
import org.extremecomponents.table.cell.Cell;
import org.extremecomponents.table.core.TableModel;
//import org.extremecomponents.table.limit.Limit;
//import org.extremecomponents.table.limit.Sort;
import org.extremecomponents.util.HtmlBuilder;

import com.et114.components.ectable.EXTableUtils;

/**
 * @author guanhw
 */
public class FuncCompAuthHrefCell implements Cell {
	protected  Log logger = LogFactory.getLog( this.getClass ( ) );
	/**
	 * 
	 */
	public FuncCompAuthHrefCell ( ) {
		// TODO Auto-generated constructor stub
	}
	
	/* (non-Javadoc)
	 * @see org.extremecomponents.table.cell.Cell#getExportDisplay(org.extremecomponents.table.core.TableModel, org.extremecomponents.table.bean.Column)
	 */
	public String getExportDisplay ( TableModel arg0 , Column arg1 ) {
		// TODO Auto-generated method stub
		return null;
	}
	
	/* (non-Javadoc)
	 * @see org.extremecomponents.table.cell.Cell#getHtmlDisplay(org.extremecomponents.table.core.TableModel, org.extremecomponents.table.bean.Column)
	 */
	public String getHtmlDisplay ( TableModel model , Column arg1 ) {
		// TODO Auto-generated method stub
		// TODO Auto-generated method stub
		HtmlBuilder html = new HtmlBuilder();
		html.td ( 0 ).xclose ( ) ;
		try {
			StringBuffer params = new StringBuffer();
			Object bean = model.getCurrentRowBean();
			String funcElementId = BeanUtils.getProperty( bean, "funcElementId" ); 
			String funcId = BeanUtils.getProperty (  bean  , "funcId" ) ;
			
			params.append (  funcElementId  ) ; 
			params.append ( "&funcId=" ).append (  funcId ) ;
			params .append (  EXTableUtils.getLimitPageParams ( model.getTableHandler ( ).getTable ( ).getTableId ( ) , model.getLimit ( ) ) ) ;
			
			html.a( "javascript:toAuths( '" + params + "' )" );
			html.xclose ( );
			html.img ( model.getContext().getContextPath() + "/themes/styles/default/images/role.png" ) ; 
			html.aEnd ( );
		} catch (Exception e) {
			logger.error ( e.getMessage ( ) , e ) ;
		}
		html.tdEnd ( );
		return html.toString();	
		}

	
	
}
